<!--入选/排除标准-->
<template>
	<div class="mcTableIndex">
		<div class="mcTableList">
			<el-table
				:data="dataList"
				border
				style="width: 100%"
				:row-style="{ height: '40px' }"
				:cell-style="{ padding: '0' }"
				height="250"
			>
				<el-table-column label="序号" align="center" width="60" fixed>
					<template slot-scope="scope">
						{{ scope.$index + 1 }}
					</template>
				</el-table-column>
				<el-table-column prop="standardName" label="标准名称" align="center">
				</el-table-column>
				<el-table-column prop="options" label="判断" align="center">
					<template slot-scope="scope">
						<slot :name="scope.row.options" :params="scope.row">
							<el-select
								style="width: 180px"
								size="small"
								v-model="scope.row.options"
								:disabled="oprType == 'view'"
								@change="
									(e) => {
										optionChange(e, scope.row)
									}
								"
							>
								<el-option
									:label="select.label"
									:value="select.value.toString()"
									v-for="(select, sIndex) in selectList"
									:key="sIndex"
								></el-option>
							</el-select>
						</slot>
					</template>
				</el-table-column>
			</el-table>
		</div>
	</div>
</template>

<script>
	import { Utility } from "@/libs/utility"
	export default {
		props: ["dataSource", "oprType"],
		computed: {
			curData() {
				return this.dataSource
			},
		},
		watch: {
			curData(newVal) {
				this.dataList = newVal
			},
		},
		data() {
			return {
				// 入选/排除标准
				selectList: Utility.getDictList("select_option"),
				dataList: [],
			}
		},
		methods: {
			optionChange(e, row) {
				let curDataList = this.dataList
				curDataList.map((t) => {
					if (t.id == row.id) {
						t.options = e
						t.optionsName = this.selectList.find((b) => b.value == e).label
					}
					return t
				})
				this.dataList = curDataList
			},
			getData() {
				return this.dataList
			},
		},
		mounted() {
			this.dataList = this.dataSource
		},
	}
</script>

<style scoped>
	.mcTableIndex {
		margin-top: 0;
	}

	.mcTableIndex .mcTableList {
		margin: 10px auto;
	}
</style>
